/**
 * @author Eliana - Matias
 */

$(function() {
    $( "#radio" ).buttonset();
  });

$(document).ready(function(){
	
		
	checkCookie();
	
});		
	

//cambiar de estilo
function cambiarCss1() {
	//System.out.println(document.getElementById("id_css").href);
	document.getElementById("css_que_cambia").href="css/estilo1.css";
	setCookie("username","css/estilo1.css",365);
	$('#logo_img').attr("src","img/LOGO1ELI.png");
	
}

function cambiarCss2() {
	//System.out.println(document.getElementById("id_css").href);
	document.getElementById("css_que_cambia").href="css/estilo2.css";
	setCookie("username","css/estilo2.css",365);
	$('#logo_img').attr("src","img/LOGO2ELI.png");

}


//chequea cual es el estilo ultimo usado para establecerlo
function checkCookie()
{
var username=getCookie("username");
if (username!=null && username!="")
  {
   document.getElementById("css_que_cambia").href=username;
   
   //alert('holaaaa'+username);
	//----------------------------------------------------
	//FALTA ESTO PERO NO SE PORQUE NO ANDA!!!!!!!!
	if(username=="css/estilo1.css")
		{
			//alert("habilirar 1!!!");
			$('#radio1').button( "enable" );
			$('#radio1').button( "refresh" );
			//var attrs = $('#label1').attr('class');
			//alert(attrs);
			$('#label1').attr('class', 'ui-button ui-widget ui-state-default ui-button-text-only ui-corner-leftui-state-active ui-state-active');
			
			$('#logo_img').attr("src","img/LOGO1ELI.png");
		
		}
	else {
			//alert("habilirar 2!!!");
		$('#radio2').button( "enable" );//.checked="checked";//attr("checked","checked");
		$('#radio2').button( "refresh" );
		$('#label2').attr('class', 'ui-button ui-widget ui-state-default ui-button-text-only ui-corner-leftui-state-active ui-state-active');
		$('#logo_img').attr("src","img/LOGO2ELI.png");
		}
	
	//---------------------------------------------------------

  }
else 
  {
    setCookie("username","css/estilo1.css",365);
    //solo la primera vez se va a setear por defecto el estilo 1
    
  }
}

function getCookie(c_name)
{
var c_value = document.cookie;
var c_start = c_value.indexOf(" " + c_name + "=");
if (c_start == -1)
  {
  c_start = c_value.indexOf(c_name + "=");
  }
if (c_start == -1)
  {
  c_value = null;
  }
else
  {
  c_start = c_value.indexOf("=", c_start) + 1;
  var c_end = c_value.indexOf(";", c_start);
  if (c_end == -1)
    {
    c_end = c_value.length;
    }
  c_value = unescape(c_value.substring(c_start,c_end));
  }
return c_value;
}

function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}
